#include<iostream>
#include<fstream>
#include <chrono>
#include<map>
#include<stdio.h>
#include <algorithm>

using namespace std;

int n;
int c;
int *p;
int *w;
int *x;
int *best_x;
int max_val = 0;
int *item_map;

void Sort(int *val, int *wt) {
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if ((double)val[i]/wt[i]*1.0 < (double)val[j]/wt[j]*1.0) {
                swap(val[i], val[j]);
                swap(wt[i], wt[j]);
                swap(item_map[i], item_map[j]); // 同时交换索引
            }
        }
    }
}

double bound(int cw, int cp, int val[], int wt[], int i) {
    int tw = c - cw;
    double ans = cp;
    int a=i-1;
    while (i < n && wt[i] <= tw) { 
        tw -= wt[i];
        ans += val[i];
        i++;
    }
    if (i < n) {
        double ratio = (double)val[i] * tw*1.0;
        ans += ratio / wt[i]* 1.0; // 使用1.0确保浮点除
    }
    return ans;
}

void Knapsack(int i, int cw, int cp, int *wt, int *val, int *best_x) {
    if (cw > c || i > n) return;
    if (cp > max_val) { 
        max_val = cp;
        for (int j = 0; j < n; j++)
            best_x[j] = x[j];
    }
    
    if (i < n) {
        x[i] = 1;
        Knapsack(i + 1, cw + wt[i], cp + val[i], wt, val, best_x);
        x[i] = 0;
        if (bound(cw, cp, val, wt, i + 1) > (double)max_val)
            Knapsack(i + 1, cw, cp, wt, val, best_x);
    }
}

void init() {
    cin >> n >> c;
    p = new int[n];
    w = new int[n];
    x = new int[n];
    item_map = new int[n];
    for (int i = 0; i < n; i++) {
        item_map[i] = i; // 保存原始索引
    }
    best_x = new int[n];
    for (int i = 0; i < n; i++) {
        x[i] = 0;
        best_x[i] = 0;
    }
    for(int i=0;i<n;i++){
        cin >> p[i]>> w[i];
    }
    Sort(p, w);
}
int main() {
    init();
    
    auto start = std::chrono::high_resolution_clock::now();
    Knapsack(0, 0, 0, w, p, best_x);

    
    cout << max_val << endl;
    int count=0;
    int *bestSelected = new int[n];
    for (int i = 0; i < n; i++) {
        if( best_x[i] == 1) {
            bestSelected[count] = item_map[i] + 1;
            count++;
        }
    }
    sort(bestSelected, bestSelected + count);
    for (int i = 0; i < count; i++) {
        cout << bestSelected[i] << " ";
    }
    cout << endl;
    auto end = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
    double time_ms = duration.count() / 1000.0;
    printf("%fms\n",time_ms);
    
    delete[] p;
    delete[] w;
    delete[] x;
    delete[] best_x;
    delete[] item_map;
    delete[] bestSelected;
    return 0;
}